package org.atlantis.evnlib;

/**
 * 事件参数。用来在事件源和事件监听器间传递。
 * 
 * @author atlantis
 * 
 */
public final class EventArg {

	private String eventName;
	private Object param;

	EventArg(String eventName, Object param) {
		this.eventName = eventName;
		this.param = param;
	}

	/** 获取事件源传递来的参数 */
	@SuppressWarnings("unchecked")
	public <T> T getParam(Class<T> type) {
		return (T) param;
	}

	/** 获取事件源传递来的参数 */
	public Object getParam() {
		return param;
	}

	/** 获取当前事件名称 */
	public String getEventName() {
		return eventName;
	}

	@Override
	public String toString() {
		return String.format("EventArg<'%s'>{param: %s}", eventName, param);
	}
}
